package com.nefu.huiyi.result;

import com.nefu.huiyi.entity.TitleStatistics;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class DoctorTitleResult<T> {
    private int code;
    private String message;
    private T data;
    private String reportTime; // 新增报表时间字段

    // 成功响应（带数据）
    public static <T> DoctorTitleResult<T> success(T data) {
        DoctorTitleResult<T> result = new DoctorTitleResult<>();
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        result.setReportTime(java.time.LocalDateTime.now().toString());
        return result;
    }

    // 成功响应（不带数据）
    public static <T> DoctorTitleResult<T> success() {
        return success(null);
    }

    // 错误响应
    public static <T> DoctorTitleResult<T> error(int code, String message) {
        DoctorTitleResult<T> result = new DoctorTitleResult<>();
        result.setCode(code);
        result.setMessage(message);
        result.setReportTime(java.time.LocalDateTime.now().toString());
        return result;
    }

    // 针对职称统计的特殊方法
    public static DoctorTitleResult<Map<String, Integer>> titleDistribution(Map<String, Integer> data) {
        DoctorTitleResult<Map<String, Integer>> result = new DoctorTitleResult<>();
        result.setCode(200);
        result.setMessage("职称分布数据获取成功");
        result.setData(data);
        result.setReportTime(java.time.LocalDateTime.now().toString());
        return result;
    }

    public static DoctorTitleResult<List<TitleStatistics>> titleStatistics(List<TitleStatistics> data) {
        DoctorTitleResult<List<TitleStatistics>> result = new DoctorTitleResult<>();
        result.setCode(200);
        result.setMessage("职称统计数据列表获取成功");
        result.setData(data);
        result.setReportTime(java.time.LocalDateTime.now().toString());
        return result;
    }
}
